import 'package:vista/shared/models/base_frame.dart';

/// 圈子快照
/// 存储圈子信息，如摄影中的快照般记录圈子特征
class GroupSnapshot extends BaseFrame {
  final String id; // 圈子ID
  final String title; // 标题
  final String image; // 圈子图片
  final DateTime createdAt; // 创建时间

  const GroupSnapshot({
    required this.id,
    required this.title,
    required this.image,
    required this.createdAt,
  });

  /// 从JSON创建圈子快照
  factory GroupSnapshot.fromJson(Map<String, dynamic> json) {
    return GroupSnapshot(
      id: json['id'] as String,
      title: json['title'] as String,
      image: json['image'] as String,
      createdAt: DateTime.parse(json['createdAt'] as String),
    );
  }

  @override
  List<Object?> get props => [id, title, image, createdAt];

  @override
  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'title': title,
      'image': image,
      'createdAt': createdAt.toIso8601String(),
    };
  }
}
